package com.hhxy.rabbitmq.demo06;

import com.hhxy.rabbitmq.utils.RabbitMqUtil;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @author ghp
 * @date 2023/2/24
 * @title 生产者
 * @description
 */
public class DirectLogs {

    // 交换机名
    public static final String EXCHANGE_NAME = "direct_logs";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtil.getChannel();
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String routingKey = sc.next();
            String message = sc.next();
            channel.basicPublish(EXCHANGE_NAME, routingKey, null, message.getBytes("UTF-8"));
            System.out.println("生产者发送消息: " + message);
        }
    }
}
